﻿using System;
using System.Linq;
using System.Web;
using System.Web.Routing;

namespace PortalIntranet.InternalComponents.Web
{
	public class UrlConstraint : IRouteConstraint
	{
		string[] internalPages = new string[]
		{
			//"Home",
			"Login",
			"Login/Logon",
			"Login/Logoff",
			"Dynamic/AtualizarLocalizacao",
			"Error/Error404"
		};

		public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
		{
			var slug = values[parameterName];

			if (slug != null)
			{
				var ret = this.internalPages.Where(c => c.ToUpper() == slug.ToString().ToUpper()).SingleOrDefault();
				return (ret == null);
			}

			return false;
		}
	}
}
